﻿#pragma once
#include<stdio.h>
#include<locale.h>
#include<stdlib.h>
#include<windows.h>
#include<stdbool.h>
#include<time.h>
#include<assert.h>

#define wall L'□'
#define BOOY L'●'
#define FOOD L'¥'
#define KEY_PRESS(VK) ( (GetAsyncKeyState(VK) & 0x1) ? 1 : 0 )
//蛇的结点
typedef struct SnakeNode
{
	int x;
	int y;
	struct SnakeNode* next;
}SnakeNode,*pSnakeNode;
enum DIRECTION
{
	UP,
	DOWN,
	LEFT,
	RIGHT
};
enum GAME_STATUS
{
	OK,
	KILL_BY_WALL,
	KILL_BY_SELF,
	END_NOMAL
};
//对象蛇
typedef struct Snake
{
	pSnakeNode _pSnake;
	pSnakeNode _pFood;//维护食物的指针
	enum DIRECTION _Dir;
	enum GAME_STATUS _Status;
	int _Socre;//获取当前的分数
	int _foodweight;//食物的分数
	int _SleepTime;//每走一步休眠的时间
}Snake,* pSnake;
void GameStart(pSnake ps);
void my_WelcomeToGame();
void CreateMap();
//设置光标位置的函数
void SetPos(short x, short y);
//初始化蛇身
void InitSnake(pSnake ps);
//初始化食物
void CreateFood(pSnake ps);
//游戏的运行
void GameRun(pSnake ps);
void PrintHelpIofo(pSnake ps);
void SnakeMove(pSnake ps);
bool NextisFood(pSnake ps, pSnakeNode newnode);
void EatFood(pSnake ps);
void NoFood(pSnake ps, pSnakeNode newnode);
bool killBYWall(pSnake ps);
bool killBYSelf(pSnake ps);
void pause();
//void GameEnd(pSnake ps);
